package ar.com.e2solver.solver;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import ar.com.e2solver.model.Puzzle;

public final class PuzzlePrinter {

	private PuzzlePrinter(){}
	
	public static void print(Puzzle puzzle) {
		FileWriter fr = null;
		PrintWriter pw = null;
		
		try {
			StringBuilder sb = new StringBuilder(System.getProperty("user.home"));
			sb.append(System.getProperty("file.separator"));
			sb.append("E2Result_");
			sb.append(System.currentTimeMillis());
			sb.append(".txt");
			
			fr = new FileWriter(sb.toString());
			fr.write(puzzle.toString());
		
		} catch (IOException e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		} finally {
			try {
				if(pw != null){
					pw.close();
				}
				if(fr != null){
					fr.close();
				}
			} catch (IOException e) {}
		}
		
	}

}
